/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package imp.command;

import dom.command.Command;
import dom.command.Result;
import dom.command.Status;
import imp.reciever.compressor.Compressor;

/**
 *
 * @author julian.pena
 */
public class Compress implements Command{
    
    private final CommandType commandType = CommandType.COMPRESS;
    private Status status;
    private Result result;
    private Compressor compressor;

    public Compress(Compressor compressor) {
        this.compressor = compressor;
        this.status = Status.NOT_STARTED;
    }

    @Override
    public void execute() {
        try {
            status = Status.IN_PROGRESS;
            compressor.action();
            status = Status.FINISHED;
            result = Result.SUCCESSFUL;
        } catch (Exception ex) {
            status = Status.FINISHED;
            result = Result.FAILED;
            System.out.println(ex.getMessage());
        }
    }

    @Override
    public Status getStatus() {
        return status;
    }

    @Override
    public Result getResult() {
        return result;
    }

    @Override
    public String getName() {
        return commandType.getStringValue();
    }

    @Override
    public void run() {
        execute();
    }
    
}
